home *** CD-ROM | disk | FTP | other *** search
- // captions.cnh
- // Standard captions
-
- // -------------------------------------------------------------
- // Constructors
- // -------------------------------------------------------------
- // Init func Predeclaration
- func Gui_Component NewCaption(Menu_Material _pFont,szx _sxTxt);
- func Gui_Component NewCaptionAspectRatio(Menu_Material _pFont,szx _sxTxt,f32x _fFontSize);
-
-
- // Messages
- message Caption(szx _szTxt);
- // -------------------------------------------------------------
- // -------------------------------------------------------------
-
- // Tools func
- func void SetCaption(szx _sxTxt);
-
- // Initializer
-
- // Message handling interface
- interface Gui_iCaption
- {
- SetCaption Caption;
- }
-
-
- // Constructor
- func Gui_Component NewCaption(Menu_Material _pFont,szx _sxTxt)
- {
- var Menu_Sprite sprite;
- var Gui_Component caption;
- var f32x w,h;
-
- // Create container with caption interface
- caption = NewContainer(Gui_iCaption);
- SetAlign(caption,e_GUI_HAlign_Left,e_GUI_VAlign_Top);
- // pdtCaption.szText = _sxTxt;
-
- // Create a sprite with material and area index e_GUI_State_Enabled
- sprite = NewSprite2D(_pFont);
- w = PrecalcTextWidth(sprite,_sxTxt);
- h = PrecalcTextHeight(sprite,_sxTxt);
- SetText(sprite,_sxTxt);
- SetShadingMode(sprite,DLC_GouraudMode_ModulateDiffuse,DLC_GouraudMode_Decal);
-
- // Attach the sprite to this container
- AttachSprite(caption,sprite);
-
- // Stretch caption to fit text
- StretchTo(caption,w,h);
-
- return caption;
- }
-
- func Gui_Component NewCaptionAspectRatio(Menu_Material _pFont,szx _sxTxt, f32x _fFontSize)
- {
- var Menu_Sprite sprite;
- var Gui_Component caption;
- var f32x w,h,factor;
-
- // Create container with caption interface
- caption = NewContainer(Gui_iCaption);
- SetAlign(caption,0,0);
-
- // Create a sprite with material and area index e_GUI_State_Enabled
- sprite = NewSprite2D(_pFont);
- SetText(sprite,_sxTxt);
- SetShadingMode(sprite,DLC_GouraudMode_ModulateDiffuse,DLC_GouraudMode_Decal);
-
- // Attach the sprite to this container
- AttachSprite(caption,sprite);
- SetScale(caption,_fFontSize*g_fScreenScaleFactor);
-
- // calcul caption size
- factor = (_fFontSize / 1.0);
- w = PrecalcTextWidth(sprite,_sxTxt) * factor;
- h = PrecalcTextHeight(sprite,_sxTxt)* factor;
-
- // Stretch caption to fit text
- StretchTo(caption,w,h);
-
- return caption;
- }
-
- func void SetCaption(szx _szTxt)
- {
- var Menu_Sprite sprite;
- var Gui_Component caption;
-
- // Retrieve caption component
- caption = GetThis();
-
- // Retrieve sprite
- sprite = GetSprite(caption);
-
- // Update text
- SetText(sprite,_szTxt);
- }
-
-